﻿using LMM_Editor.Classes.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LMM_Editor.Classes.System
{
    public class InputHandler
    {
        public ToolManager toolManager;

        public InputHandler()
        {
            //entityManager = new EntityManager();
            toolManager = new ToolManager();
        }

        public void onClick(double x, double y, Control control)
        {
            // Find any entities at the mouse pos
            IEntity entity = EntityManager.findEntity(control);
            if (entity != null)
            {
          
            }

            IEntity e = toolManager.useTool((int)x, (int)y, entity);
            if (e != null && toolManager.selectedTool.tooltype == ToolType.Create)
            {
                //e.component.MouseClick += new MouseEventHandler(toolManager.selectTool.useToolConvert);
                e.component.MouseDown += new MouseEventHandler(toolManager.selectTool.useToolConvert);
                e.component.MouseMove += new MouseEventHandler(toolManager.selectTool.useToolMove);
                e.component.MouseUp += new MouseEventHandler(toolManager.selectTool.useToolEndConvert);
            }
        }

        public void onClickRelease(double x, double y, Control control)
        {
            IEntity entity = EntityManager.findEntity(control);
            toolManager.useToolEnd((int)x, (int)y, entity);
        }
    }
}
